package com.csweimei.rentmanagementtreasure.tenant.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppViewModelFactory;
import com.csweimei.rentmanagementtreasure.databinding.LayoutFTwoBinding;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.FTwoVM;
import com.gtdev5.geetolsdk.mylibrary.util.LogUtils;
import com.haibin.calendarview.Calendar;
import com.haibin.calendarview.CalendarView;

import java.util.HashMap;
import java.util.Map;

import me.goldze.mvvmhabit.base.BaseFragment;

public class TabTwoFragment extends BaseFragment<LayoutFTwoBinding, FTwoVM> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.layout_f_two;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(getActivity());


        binding.cur.setOnClickListener(v -> binding.calendarView.scrollToCurrent());
        binding.calendarView.setOnCalendarSelectListener(new CalendarView.OnCalendarSelectListener() {
            @Override
            public void onCalendarOutOfRange(Calendar calendar) {

            }

            @Override
            public void onCalendarSelect(Calendar calendar, boolean isClick) {
                viewModel.selDate.set(calendar.getYear()+"-"+calendar.getMonth() + "-" + calendar.getDay());
                viewModel.onResume();
            }
        });
    }


    @Override
    public FTwoVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this,factory).get(FTwoVM.class);
    }
}
